import os
from dotenv import load_dotenv, find_dotenv

# --- .env 文件加载 ---
dotenv_path = find_dotenv()
if dotenv_path:
    print(f"成功加载 .env 文件: {dotenv_path}")
    load_dotenv(dotenv_path)
else:
    print("警告: 未找到 .env 文件。请确保它位于项目根目录中。")

# --- LLM 配置 ---
LLM_PROVIDER = os.getenv("LLM_PROVIDER", "openai").lower()

# API Keys
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
ZHIPU_API_KEY = os.getenv("ZHIPU_API_KEY")

# Model Names
OPENAI_MODEL_NAME = os.getenv("OPENAI_MODEL_NAME", "gpt-4o")
ZHIPU_MODEL_NAME = os.getenv("ZHIPU_MODEL_NAME", "glm-4")

# --- 打印加载的配置以供调试 ---
print("--- 应用配置 ---")
print(f"LLM 提供商: {LLM_PROVIDER}")

if LLM_PROVIDER == 'zhipu':
    if ZHIPU_API_KEY:
        print(f"智谱 (Zhipu) API Key: 已加载")
    else:
        print("警告: ZHIPU_API_KEY 未设置。")
    print(f"智谱 (Zhipu) 模型: {ZHIPU_MODEL_NAME}")

elif LLM_PROVIDER == 'openai':
    if OPENAI_API_KEY:
        print(f"OpenAI API Key: 已加载")
    else:
        print("警告: OPENAI_API_KEY 未设置。")
    print(f"OpenAI 模型: {OPENAI_MODEL_NAME}")

print("-----------------")
